#include <ctime>
#include <iostream>
#include <stack>
#include <unordered_map>
using namespace std;

const int kMaxN = 2e5 + 10;

int a[kMaxN], f[kMaxN], pre[kMaxN];

int mapping(int x) {
  static int t = (int)time(NULL);

  return x ^ t;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, ans = 0, end = 0;
  unordered_map<int, int> val2pos;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    pre[i] = val2pos[mapping(a[i] - 1)];
    f[i] = f[pre[i]] + 1;
    val2pos[mapping(a[i])] = i;
    if (ans < f[i]) {
      ans = f[i];
      end = i;
    }
  }

  stack<int> res;

  while (end) {
    res.push(end);
    end = pre[end];
  }
  cout << ans << "\n";
  while (!res.empty()) {
    cout << res.top() << " ";
    res.pop();
  }
  cout << "\n";
  return 0;
}